// 对返回数据进行包装
class BaseModel {
  constructor(data, message) {
    if (typeof data === 'string') {
      this.message = data
      data = null
      message = null
    }
    if (data) {
      this.data = data
    }
    if (message) {
      this.message = message
    }
  }
}
// 返回成功数据结构
class SuccessModel extends BaseModel {
  constructor(data, message) {
    super(data, message)
    this.state = 0
  }
}
// 返回失败数据结构
class ErrorModel extends BaseModel {
  constructor(data, message) {
    super(data, message)
    this.state = -1
  }
}

module.exports = {
  SuccessModel,
  ErrorModel
}
